Skip to content

fix(render): edge environment errors with MessageChannel #2225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

gabrielmfern
Copy link
Member

@gabrielmfern gabrielmfern commented May 7, 2025

This is meant for partially fixing #1630 which is caused by a browser JS API trying to be used on the edge environment. React DOM does provide this react-dom/server.edge export that you can use which doesn't use that API, and works for raw edge environments, like Cloudflare Workers. I've tested this on our Cloudflare Workers Example

But, when running in Next.js on the edge, this error happens after this pull request:

(rsc)/./node_modules/@react-email/render/dist/edge-light/index.js
  Error [TypeError]: Cannot set properties of undefined (setting 'recentlyCreatedOwnerStacks')
    at new Promise (<anonymous>)
    at Generator.next (<anonymous>)

And according to vercel/next.js#71865, this happens because we're running React DOM in a React Server environment which isn't really allowed. Not sure what we can do to actually circumvent this, except for waiting for https://github.com/facebook/react/tree/main/packages/react-markup to get into a stable version, or use the experimental itself.

Copy link

changeset-bot bot commented May 7, 2025

🦋 Changeset detected

Latest commit: 8549fa1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@react-email/render Patch
@react-email/components Patch
playground Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented May 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
react-email Ready Ready Preview Comment Aug 19, 2025 5:43pm
react-email-demo Ready Ready Preview Comment Aug 19, 2025 5:43pm

Copy link

pkg-pr-new bot commented May 7, 2025

Open in StackBlitz

npm i https://pkg.pr.new/resend/react-email/@react-email/render@2225

commit: 8549fa1

@adrai
Copy link

adrai commented Jul 31, 2025

Does this address also this issue? #1630

@gabrielmfern
Copy link
Member Author

gabrielmfern commented Aug 19, 2025

@adrai yes, but introduces another error for Next.js running on the edge

@gabrielmfern gabrielmfern marked this pull request as ready for review August 19, 2025 17:06
@gabrielmfern gabrielmfern requested a review from a team as a code owner August 19, 2025 17:06
@gabrielmfern gabrielmfern requested review from rehanvdm and removed request for a team August 19, 2025 17:06
@gabrielmfern gabrielmfern changed the title feat(render): Use react-dom/server.edge on edge environments fix(render): edge environment errors with MessageChannel Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants